import time

import pynput
import pyperclip
from pynput.keyboard import Key, Listener

flag = False
option2 = input("请选择合成模式：\n0:自定义 \n1:前后缀 \n")
str1 =""
prefix =""
postfix =""
myFormat = ""
if option2 == "1":
    option = input("前后缀选择：\n0:自定义\n1: private String ();\n2:(),")

    if option=="0":
        prefix =input("请输入前缀\n")
        postfix = input("请输入后缀\n")
    if option =="1":
        print(000)
        prefix ="private String "
        postfix = ";"
    if option =="2":
        postfix=","
if option2 == "0":
    myFormat = input("输入format： **{}**  {}将被复制的内容覆盖\n")

def on_press(key):
    pass

def on_release(key):
    global  prefix
    global  postfix
    global  str1
    global  myFormat
    try:
        if key == Key.esc:
            str1 = ""
            return False
        elif key ==Key.enter:
            pass
        elif key == Key.left:
            str1 = ""
            print(str1)
        elif not key == Key.ctrl_l:
            if option2 == "1" :
                str1 = str1 + prefix + pyperclip.paste() + postfix;
            if option2 == "0" :
                str1 =str1 + myFormat.replace("{}",pyperclip.paste())
            pyperclip.copy(str1)
            print(str1)

    except AttributeError:
        print()

def func():

    with Listener(
    on_press=on_press,
    on_release=on_release) as listener:
        listener.join()

while True:
    input("输入 a 继续\n")
    func()